home *** CD-ROM | disk | FTP | other *** search
- Path: newsfeed.internetmci.com!iol!usenet
- From: mat8033@iol.ie (Stuart Mc Bride)
- Newsgroups: comp.lang.c++
- Subject: Re: Getting the system time and date
- Date: Tue, 30 Jan 1996 09:09:00 GMT
- Organization: Ireland On-Line
- Message-ID: <4ejr3d$h9q@barnacle.iol.ie>
- References: <tate.1.002C7F92@netwest.com> <4duk43$8ql@barnacle.iol.ie> <4e2qfg$pdr@locutus.rchland.ibm.com>
- NNTP-Posting-Host: dialup-186.dublin.iol.ie
- X-Newsreader: Forte Free Agent 1.0.82
-
- pstaite@vnet.ibm.com wrote:
-
- >In <4duk43$8ql@barnacle.iol.ie>, mat8033@iol.ie (Stuart Mc Bride) writes:
- >>tate@netwest.com (Tate Griffin) wrote:
- >>
- >>>How do I get the current time and date from a PC using C++?
- >>
-
- >Wow that was complicated, why not just use this (which will work on most
- >systems, not just the PC):
-
- >#include<iostream.h>
- >#include<time.h>
-
- >int main() {
- > cout << ctime( time( 0 ) ) << endl;
- > return 0; }
-
-
- >Phil Staite, team OS/2
- >internet: pstaite@vnet.ibm.com internal: pstaite@rchland
-
- Okay, so that's shorter, but I'd hardly call my way complicated.
- What's more, it may be just me, but that won't work in BC++3.1
-
- This however will:
-
- #include <stdio.h>
- #include <time.h>
-
- int main()
- {
- time_t t;
- time(&t);
- printf("Today's date and time: %s\n",ctime(&t));
- return 0;
- }
-
- --- Stuart --- mat8033@iol.ie
- c2smcbri@compapp.dcu.ie
-
- http://www.compapp.dcu.ie/~c2smcbri
-
- - Gross Incompetence = 144 Computer Programmers -
-
-